#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
char ubuf[2] = {0};
int main(int argc, char const *argv[])
{
    int fd = open("/dev/myled", O_RDWR);
    if (fd == -1) {
        perror("open");
        return -1;
    }

    while (1) {
        // led1
        ubuf[0] = 1;
        ubuf[1] = 1;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
        ubuf[1] = 0;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
        // led2
        ubuf[0] = 2;
        ubuf[1] = 1;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
        ubuf[1] = 0;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
        // led3
        ubuf[0] = 3;
        ubuf[1] = 1;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
        ubuf[1] = 0;
        write(fd,ubuf,sizeof(ubuf));
        sleep(1);
    }
    close(fd);
    return 0;
}
